package cloud.xlh.infrastructure.mq.operate;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2022/11/25 11:34
 * @ Description: 提供基础的，相对原子简洁的消息推送和消费api
 */
public interface MQOperateService<T extends BaseMQOperateParamIn<T> , R extends BaseMQOperateParamOut> {
    default R sendMessage(T t ,R r) {
        //前置处理  实现
        r = sendMessagePreHandle(t , r);
        //三方包提供的api固定 函数式接口
        r = doSendMessage(t , r);
        //后置处理  实现
        r = sendMessagePostHandle(r);
        return r;
    }

    default R doSendMessage(T t , R r) {
        return (R)t.getMqSendMessageFunctionInterface().sendMessage(t , r);
    }

    R sendMessagePostHandle(R r);

    R sendMessagePreHandle(T t , R r);

    default void consumeMessage(T t) {

    }
}
